//
//  AffirmOrderFooterView.m
//  much
//
//  Created by weijunjie on 2019/1/10.
//  Copyright © 2019年 iOS. All rights reserved.
//

#import "AffirmOrderFooterView.h"

@interface AffirmOrderFooterView ()

@property (strong, nonatomic) UILabel *totalLabel; //总计
@property (strong, nonatomic) UILabel *freightLabel; //运费

@end
@implementation AffirmOrderFooterView
- (instancetype)init {
    self = [super init];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        self.frame = CGRectMake(0, 0, ScreenWidth, 80);
    }
    return self;
}
- (UILabel *)totalLabel {
    if (!_totalLabel) {
        UILabel * lab = [[UILabel alloc] init];
        lab.font = APPFONT(15);
        lab.textColor = Color34;
        lab.text = @"商品总金额";
        [self addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(15);
            make.top.equalTo(self);
            make.height.mas_equalTo(40);
        }];
        
        _totalLabel = [[UILabel alloc] init];
        _totalLabel.textColor = Color175030;
        _totalLabel.font = APPFONT(15);
        [self addSubview:_totalLabel];
        [_totalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).with.offset(-15);
            make.top.bottom.equalTo(lab);
        }];
        
        UIView * line = [[UIView alloc] init];
        line.backgroundColor = Color217;
        [self addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(lab);
            make.top.equalTo(lab.mas_bottom);
            make.height.mas_equalTo(0.5);
            make.right.equalTo(self);
        }];
    }
    return _totalLabel;
}

- (UILabel *)freightLabel {
    if (!_freightLabel) {
        UILabel * lab = [[UILabel alloc] init];
        lab.font = APPFONT(15);
        lab.textColor = Color34;
        lab.text = @"运费";
        [self addSubview:lab];
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.totalLabel.mas_bottom);
            make.height.equalTo(self.totalLabel);
            make.left.equalTo(self).offset(15);
        }];
        
        _freightLabel = [UILabel new];
        _freightLabel.textColor = Color175030;
        _freightLabel.font = APPFONT(15);
        [self addSubview:_freightLabel];
        [_freightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.totalLabel);
            make.top.bottom.equalTo(lab);
        }];
    }
    return _freightLabel;
}

- (void)setOrderWithTotalAmount:(NSString *)totalAmount totalFreight:(NSString *)totalFreight {
    self.totalLabel.text = [NSString stringWithFormat:@"¥ %@",totalAmount];
    self.freightLabel.text = [NSString stringWithFormat:@"¥ %@",totalFreight];;
}

@end
